import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;
import java.util.HashMap;

public class ImageLoader
{
	protected HashMap<String, BufferedImage> images;

	public ImageLoader()
	{
		images = new HashMap<String, BufferedImage>();
 	}

	public BufferedImage getImage(String s)
	{
		BufferedImage b = (BufferedImage) images.get(s);
		if (b == null)
		{
			URL u = null;
			u = getClass().getClassLoader().getResource(s);
			try
			{
				b = (BufferedImage) ImageIO.read(u);
				images.put(s, b);
			}
			catch(Exception e){System.out.println("Image failed to load.");}
		}
		return b;
	}
}